import { Dimensions,Platform } from 'react-native'

//动态计算ui大小
export const { width} = Dimensions.get('window')
export const height=Dimensions.get('window').height;
export function getPixel(num, designWidth = 375) {
  return (num * width) / designWidth
}
let windowSize = Dimensions.get('window')
let IPHONE_X_HEIGHT = 812
let IPHONE_XS_MAX_XR = 896
function isIphoneX() {
  return (
    (Platform.OS === 'ios' &&
      !Platform.isPad &&
      !Platform.isTVOS &&
      windowSize.height === IPHONE_X_HEIGHT) ||
    windowSize.width === IPHONE_X_HEIGHT ||
    windowSize.height === IPHONE_XS_MAX_XR ||
    windowSize.width === IPHONE_XS_MAX_XR
  )
}

export function getPeriDate(start, end) {
  var y = start.split('-')[0];
  var m = start.split('-')[1];
  var d = start.split('-')[2];
  var d1 = end.split('-')[2]
  var arr = {}
  for (var i = d; i < d1; i++) {
    Object.assign(arr,
      {
        [y + '-' + m + '-' + i]: { selected: true, color: 'blue', textColor: 'white' }
      })
  }
  return arr;
}
export function formatDate(date) {
  var temp = date.split("-");
  console.log('temp', temp)
  if (!date){
    return '请选择'
  }
    return `${temp[0]}年${temp[1]}月${temp[2]}日`
}
export const topMargin = Platform.OS === 'ios' ? (isIphoneX() ? 44 : 24) : 0;
